package com.seguriapp.entities;

import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.seguriapp.base.BaseEntity;

/**
 * Represents a Procedure entity.
 * 
 * @author Tania Gonzales(taniadgv@gmail.com)
 */
@Entity
@Table(name = "Paperwork")
public class Paperwork extends BaseEntity {

  private static final long serialVersionUID = -2294496929399833497L;

  @Id
  @GeneratedValue
  private Long id;

  private String name;
  private String cost;
  private String duration;
  private boolean active;
  private boolean hasFile;

  @Transient
  private List<PaperworkAttribute> attributeList;

  public Long getId() {
    return id;
  }

  public void setId(final Long id) {
    this.id = id;
  }

  public String getName() {
    return name;
  }

  public void setName(final String name) {
    this.name = name;
  }

  public String getCost() {
    return cost;
  }

  public void setCost(final String cost) {
    this.cost = cost;
  }

  public String getDuration() {
    return duration;
  }

  public void setDuration(final String duration) {
    this.duration = duration;
  }

  public boolean isActive() {
    return active;
  }

  public void setActive(final boolean active) {
    this.active = active;
  }

  public List<PaperworkAttribute> getAttributeList() {
    return attributeList;
  }

  public void setAttributeList(final List<PaperworkAttribute> attributeList) {
    this.attributeList = attributeList;
  }

  public boolean isHasFile() {
    return hasFile;
  }

  public void setHasFile(final boolean hasFile) {
    this.hasFile = hasFile;
  }

  @Override
  public Map<?, ?> toJsonString() {
    final Map<String, Object> map = new LinkedHashMap<String, Object>();
    map.put("id", id);
    map.put("name", name);
    map.put("cost", cost);
    map.put("duration", duration);
    map.put("active", active);
    map.put("hasFile", hasFile);
    final List<Map<?, ?>> l1 = new LinkedList<Map<?, ?>>();
    for (final BaseEntity entity : attributeList) {
      l1.add(entity.toJsonString());
    }
    map.put("attributeList", l1);
    return map;
  }

}
